package com.carl.zlds.controller.web;

import com.carl.zlds.tool.common.PageBO;
import com.carl.zlds.tool.common.result.Result;
import com.carl.zlds.annotation.Login;
import com.carl.zlds.pojo.dto.CustomerServiceSearchDTO;
import com.carl.zlds.pojo.vo.CustomerServiceVO;
import com.carl.zlds.service.ICustomerServiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author carl
 */
@Slf4j
@RestController(value = "web.customerServiceController")
@RequestMapping("/web/customer-service")
@Api(tags = {"客户端 - 客服管理"})
public class CustomerServiceController {

    private final ICustomerServiceService customerServiceService;

    @Autowired
    public CustomerServiceController(ICustomerServiceService customerServiceService) {
        this.customerServiceService = customerServiceService;
    }

    @ApiOperation("客服查询")
    @GetMapping(value = "/search")
    @Login(needToken = false)
    public Result<CustomerServiceVO> search(CustomerServiceSearchDTO dto) {
        CustomerServiceVO result = customerServiceService.searchCustomerService(dto);
        return Result.success(result);
    }

    @ApiOperation("客服列表")
    @GetMapping(value = "/list")
    @Login(needToken = false)
    public Result<Map<String, Object>> list(@RequestParam(value = "gameId", defaultValue = "0") Long gameId) {
        Map<String, Object> result = customerServiceService.getCustomerServiceListByGameId(gameId);
        return Result.success(result);
    }
}
